package com.zlm.weather.controller;

import com.zlm.weather.quartz.ApiWeatherDataSyscJob;
import com.zlm.weather.util.ConfigProperties;
import org.minbox.framework.api.boot.plugin.quartz.ApiBootQuartzService;
import org.minbox.framework.api.boot.plugin.quartz.wrapper.support.ApiBootLoopJobWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: 郑
 * @Date: Create in 2020-1-18.
 */
@RestController
public class ApiBootQuartController {

    @Autowired
    private ConfigProperties configProperties;
    @Autowired
    private ApiBootQuartzService apiBootQuartzService;

    @RequestMapping("/Job")
    public String startJob(){

        String jobKey = apiBootQuartzService.newJob(
                ApiBootLoopJobWrapper.Context()
                    .loopIntervalTime(Integer.valueOf(configProperties.getWeather_timeout()))
                    .jobClass(ApiWeatherDataSyscJob.class)
                .wrapper()

        );
        return jobKey;
    }
}
